import { ComponentProps, Hook, VueComponent } from "vue3-oop"
import { NFormItem,NSwitch } from 'naive-ui';
import SwitchProps from './SwitchProps'
import styles from './SwitchDraft.module.scss'
import { FormData,WidgetNode } from '../../../types'

interface IProps {
  formData: FormData,
  widgetNode: WidgetNode
}
export default class SwitchDraft extends VueComponent<IProps> {
  static defaultProps: ComponentProps<IProps> = {
    formData: {},
    widgetNode: {}
  }

  constructor() {
    super();
  }

  render(){
    const { widgetNode } = this.props;
    const widgetProps = widgetNode.widgetProps as SwitchProps;

    const isRequired = widgetProps.layout_status==='4'

    return(
      <NFormItem
        label={widgetProps.field_label}
        labelPlacement="left"
        labelAlign={widgetProps.formitem_labelAlign}
        labelWidth={widgetProps.formitem_labelWidth}
      >
        <NSwitch
          value={'true'==widgetProps.field_default}
          onUpdateValue={(value)=>{widgetProps.field_default = ""+value}}
        />
      </NFormItem>
    )
  }
}